package com.summit.exam.servlet;



import com.summit.exam.dbdao.PaperDao;
import com.summit.exam.entity.PaperBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;


public class studentSelectPaperServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");

        String Id = req.getParameter("paperId");
        PaperDao paperService = new PaperDao();
        ArrayList<PaperBean> allPaper = new ArrayList<PaperBean>();

        //当输入为空时
        if(Id==""){
            allPaper = paperService.selectPerpar();
        }
        else{
            //输入数字
            allPaper.add(paperService.oneselectInfo(Id));
        }

        req.setAttribute("allPaper", allPaper);
        req.getRequestDispatcher("/ExamSystem/techweb/StudentSelectPaper.jsp").forward(req, resp);
    }

}
